package chapter.android.aweme.ss.com.homework;

import android.os.Bundle;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * 作业1：
 * 打印出Activity屏幕切换 Activity会执行什么生命周期？
 *
 * oncreate ons
 */
public class Exercises1 extends AppCompatActivity {

    private static final String TAG = "The current status is ";

    private TextView lifeStateDisplay;
    private Button bt;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_log);
        lifeStateDisplay = findViewById(R.id.logDisplay);
        bt = findViewById(R.id.clearButton);

        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                lifeStateDisplay.setText("");
            }
        });

        Log.i(TAG, "onCreate");

        lifeStateDisplay.append(TAG + "onCreate\n");
    }

    protected void onStart(){
        super.onStart();
        Log.i(TAG, "onStart");
        lifeStateDisplay.append(TAG + "onStart\n");
    }

    protected void onRusume(){
        super.onResume();
        Log.i(TAG, "onResume");
        lifeStateDisplay.append(TAG + "onResume\n");
    }

    protected void onPause(){
        super.onPause();
        Log.i(TAG, "onPause");
        lifeStateDisplay.append(TAG + "onPause\n");
    }

    protected void onStop(){
        super.onStop();
        Log.i(TAG, "onStop");
        lifeStateDisplay.append(TAG + "onStop\n");
    }

    protected void onDestroy(){
        super.onDestroy();
        Log.i(TAG, "onDestroy");
        lifeStateDisplay.append(TAG + "onDestroy\n");
    }

    protected void onRestart(){
        super.onRestart();
        Log.i(TAG, "onRestart");
        lifeStateDisplay.append(TAG + "onRestart\n");
    }

}
